#include <iostream>

using namespace std;
class Solution
{
public:
    /**
     * @brief 1 <= word.length <= 100
     *  word consists of lowercase and uppercase English letters.
     * @param word
     * @return true
     * @return false
     */
    bool detectCapitalUse(string word)
    {
        int wordLen = word.length();
        for (int i = 0; i < wordLen; i++)
        {
            if (word[i] >= 'A' && word[i] <= 'Z')
            {
                // Cap str
                if (word[i + 1] >= 'a' && word[i + 1] <= 'z')
                {
                    if (i + 2 < wordLen && word[i + 2] >= 'A' && word[i + 2] <= 'Z')
                    {
                        return false;
                    }
                }
                // all upper strs
                else
                {
                    if (word[i + 2] >= 'a' && word[i + 2] <= 'z')
                    {
                        return false;
                    }
                }
            }
            else
            {
                // all lowers
                if (word[i + 1] >= 'A' && word[i + 1] <= 'Z')
                {
                    return false;
                }
            }
        }
        return true;
    }

    bool detectCapitalUse_2(string word)
    {
        int wordLen = word.length();
        if (2 > wordLen)
        {
            return true;
        }
        int lower[26] = {0}, upper[26] = {0};

        for (int i = 0; i < wordLen; i++)
        {
            if (isupper(word[i]))
            {
                upper[word[i] - 'A']++;
            }
            else
            {
                lower[word[i] - 'a']++;
            }
        }

        int Lcnt = 0, Uprcnt = 0;
        for (int i = 0; i < 26; i++)
        {
            if (lower[i] > 0)
            {
                Lcnt += lower[i];
            }
            if (upper[i] > 0)
            {
                Uprcnt += upper[i];
            }
        }

        if (Lcnt == wordLen || Uprcnt == wordLen || (isupper(word[0]) && Lcnt == wordLen - 1))
        {
            return true;
        }

        return false;
    }

    bool detectCapitalUse_3(string word)
    {
        int wordLen = word.length();
        int lowerCount = 0, upperCount = 0;
        for (char w : word)
        {
            isupper(word[i]) ? upperCount++ : lowerCount++;
        }
        return lowerCount == wordLen || upperCount == wordLen || (isupper(word[0]) && lowerCount == wordLen - 1);
    }
};
int main()
{
    Solution s;
    cout << s.detectCapitalUse("FFFFFFFFFFFFFFFFFFFFf") << endl;
    return 0;
}